import SysLogAPI from "@/api/log";
import type {SysLogQuery} from "@/api/log/model";
import type {IContentConfig} from "@/components/PageContent/index.vue";

const contentConfig: IContentConfig<SysLogQuery> = {
    pageName: "sys:log",
    table: {
        border: true,
        highlightCurrentRow: true,
    },
    indexAction: function (params) {
        if ("createAt" in params) {
            const createAt = params.createAt as string[];
            params.startTime = createAt[0];
            params.endTime = createAt[1];
            delete params.createAt;
        }
        return SysLogAPI.listPage(params);
    },
    pk: "id",
    toolbar: [],
    cols: [
        {label: "编号", align: "center", prop: "id", show: false},
        {label: "接口名称", align: "center", prop: "name"},
        {label: "接口地址", align: "center", prop: "url", expand: true},
        {label: "参数", align: "center", prop: "params", expand: true},
        {label: "访问人IP", align: "center", prop: "ip"},
        {label: "访问人ID", align: "center", prop: "userId", show: false},
        {label: "访问人", align: "center", prop: "username"},
        {label: "状态", align: "center", prop: "status"},
        {label: "访问耗时", align: "center", prop: "executeTime"},
        {
            label: "访问开始时间",
            align: "center",
            prop: "createTime",
            template: "date",
            dateFormat: "YYYY-MM-DD HH:mm:ss"
        },

    ],
};

export default contentConfig;
